package com.ls.modules.sys.biz.manager;

import com.ls.common.baseClass.BackStageService;
import com.ls.modules.sys.dal.jpa.dao.SysUserDao;
import com.ls.modules.sys.dal.jpa.dao.SysUserTokenDao;
import com.ls.modules.sys.dal.jpa.entity.SysCaptchaEntity;
import com.ls.modules.sys.dal.jpa.entity.SysUserEntity;
import com.ls.modules.sys.dal.jpa.entity.SysUserTokenEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Optional;

/**
 * @author: xiaosu
 * @date: 2018-09-25  17:27
 */
@Service("shiroManager")
public class ShiroManager extends BackStageService {

    @Autowired
    private SysUserTokenDao  sysUserTokenDao;

    @Autowired
    private SysUserDao  sysUserDao;

    /**
     * 根据token  查询 实体
     * @param token
     * @return
     */
    public SysUserTokenEntity  queryByToken(String  token){

        return   sysUserTokenDao.queryByToken(token);

    }

    /**
     * 根据用户ID，查询用户
     * @param userId
     */
   public  SysUserEntity queryByUserId(Long userId){
       Optional<SysUserEntity> optional=  sysUserDao.findById(userId);

       return  optional.isPresent()?optional.get():new SysUserEntity();

   }


}
